//
//  ZBAppManager+Launch.m
//  XZBProduct
//
//  Created by xzb on 2018/10/10.
//  Copyright © 2018 xzb. All rights reserved.
//

#import "ZBAppManager+Launch.h"

@implementation ZBAppManager (Launch)
- (void)setupLaunchViewController
{
    kStartTime;
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    NSString *launchVc = [self.configDict zb_safeStringValueForKey:@"launchVC" defaultValue:@""];
    UIViewController *vc = [[NSClassFromString(launchVc) alloc] init];
    @weakify(self);
    vc.zbPageResultBlock = ^(id obj) {
        @strongify(self);
        [self setupRootController];
    };
    self.window.rootViewController = vc;
    [self.window makeKeyAndVisible];
    kEnd(@"setupLaunchViewController");
}

- (void)setupRootController
{
    kStartTime;
    NSString *rootVc = [self.configDict zb_safeStringValueForKey:@"rootVc" defaultValue:@""];
    UIViewController *vc = [[NSClassFromString(rootVc) alloc] init];
    ZBNavigationController *nav = [[ZBNavigationController alloc] initWithRootViewController:vc];
    self.keyWindow.rootViewController = nav;
    kEnd(@"setupRootController");
}
@end
